/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef _THREAD_H_
#define _THREAD_H_

#include <NoCopy.h>

namespace liba
{
namespace threads
{



class Thread : private Nocopy
{
public:
	class Impl;

    Thread();
    virtual ~Thread();
	bool set_priority( int priority ); // -2..+2
	// TODO: Conditionally include following two methods depending on platform.
	void resume();
	void suspend();
protected:
	void wait_termination(); // After the wait_termination call, you can start the Thread again.
	void request_termination();
	bool need_termination() volatile const;
    bool start();
	// if the thread is running, start returns false, until you call wait_termination
    virtual void run()=0;
private:
    unsigned long processID;
	volatile bool need_termination_flag;
	Impl * impl;
	friend class Impl;
};


} //namespace threads
} //namespace liba
using namespace liba;

#endif // _THREAD_H_
